package cn.lds.j368.dsbank.controller;

import com.github.tobato.fastdfs.domain.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

@Controller
@RequestMapping("test_fast")
public class FdfsTestController {

    @Autowired
    private FastFileStorageClient fastFileStorageClient;

    @GetMapping("/tf")
    @ResponseBody
    public String test() throws FileNotFoundException {

        System.out.println(fastFileStorageClient);

        File file = new File("C:\\Users\\cyliu\\Desktop\\temp\\id.png");

        StorePath storePath = fastFileStorageClient.uploadFile(new FileInputStream(file), file.length(), "png", null);

        System.out.println(storePath.getFullPath());
        System.out.println(storePath.getPath());

        return "test";
    }
}
